<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\ValidationException;


/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

require __DIR__ . '/fake.php';      // 引入假的路由

require __DIR__ . '/unity.php';      // 引入假的路由

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

//验证相关
Route::post('/user/create', [\App\Http\Controllers\AuthController::class, 'register']);
Route::post('/user/login', [\App\Http\Controllers\AuthController::class, 'login']);
Route::post('/user/logout', [\App\Http\Controllers\AuthController::class, 'logout']);



Route::middleware('auth:sanctum')->group(function() {
    Route::post('/user/test', [\App\Http\Controllers\AuthController::class, 'test']);
    Route::post('/user/logout', [\App\Http\Controllers\AuthController::class, 'logout']);
    //用户相关
    Route::post('/user/userAdd', [\App\Http\Controllers\UserController::class, 'userAdd']);
    Route::get('/user/userIndex', [\App\Http\Controllers\UserController::class, 'userIndex']);
    Route::delete('/user/userDel/{id}', [\App\Http\Controllers\UserController::class, 'userDel']);
    //权限相关
    Route::apiResource('menus', \App\Http\Controllers\MenuController::class);
    Route::post('/menus/loginMenu', [\App\Http\Controllers\MenuController::class, 'loginMenu']);
    //角色相关
    Route::apiResource('roles', \App\Http\Controllers\RoleController::class);
    Route::post('/roles/setMenus', [\App\Http\Controllers\RoleController::class, 'setMenus']);
    Route::post('/roles/getMenus', [\App\Http\Controllers\RoleController::class, 'getMenus']);
    //部门相关
    Route::apiResource('depts', \App\Http\Controllers\DeptController::class);
    //图片相关
    Route::post('/upload', [\App\Http\Controllers\ImageController::class, 'upload']);
    //楼层信息相关
    Route::get('/floor/list', [\App\Http\Controllers\FloorController::class, 'floorList']);
    Route::post('/floor/add', [\App\Http\Controllers\FloorController::class, 'floorAdd']);
    Route::delete('/floor/del/{id}', [\App\Http\Controllers\FloorController::class, 'floorDel']);
    Route::post('/floor/addImage', [\App\Http\Controllers\FloorController::class, 'addImage']);
    Route::post('/room/add', [\App\Http\Controllers\RoomController::class, 'roomAdd']);
    Route::get('/room/list', [\App\Http\Controllers\RoomController::class, 'roomList']);
    Route::delete('/room/del/{id}', [\App\Http\Controllers\RoomController::class, 'roomDel']);
    Route::post('/area/add', [\App\Http\Controllers\AreaController::class, 'areaAdd']);
    Route::get('/area/list', [\App\Http\Controllers\AreaController::class, 'areaList']);
    Route::delete('/area/del/{id}', [\App\Http\Controllers\AreaController::class, 'areaDel']);
    // 设备相关
    Route::get('/device/list', [\App\Http\Controllers\DeviceController::class, 'deviceList']);
    Route::get('/device/iotList', [\App\Http\Controllers\DeviceController::class, 'iotList']);
    Route::get('/device/deviceTypeList', [\App\Http\Controllers\DeviceController::class, 'deviceTypeList']);
    Route::post('/device/add', [\App\Http\Controllers\DeviceController::class, 'deviceAdd']);
    Route::delete('/device/del/{id}', [\App\Http\Controllers\DeviceController::class, 'deviceDel']);
    Route::get('/device/branch/list', [\App\Http\Controllers\BranchController::class, 'branchList']);
    Route::post('/device/branch/add', [\App\Http\Controllers\BranchController::class, 'branchAdd']);
    Route::delete('/device/branch/del/{id}', [\App\Http\Controllers\BranchController::class, 'branchDel']);
    // model 相关
    Route::get('/model/list', [\App\Http\Controllers\DeviceModelController::class, 'modelList']);
    Route::post('/model/add', [\App\Http\Controllers\DeviceModelController::class, 'modelAdd']);
    Route::delete('/model/del/{id}', [\App\Http\Controllers\DeviceModelController::class, 'modelDel']);
    // 485model 相关
    Route::get('/bind/list', [\App\Http\Controllers\DeviceBindingController::class, 'bindList']);
    Route::post('/bind/add', [\App\Http\Controllers\DeviceBindingController::class, 'bindAdd']);
    Route::delete('/bind/del/{id}', [\App\Http\Controllers\DeviceBindingController::class, 'bindDel']);



    //停车场相关
    //Route::get('/parking/add', [\App\Http\Controllers\ParkingController::class, 'add']); // 批量插入数据库，假数据

});
